package com.taiyo.modules.api.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.taiyo.modules.api.entity.TIdentityItemEntity;
import com.taiyo.modules.api.service.TIdentityItemService;
import com.taiyo.common.utils.PageUtils;
import com.taiyo.common.utils.Query;
import com.taiyo.common.utils.R;




/**
 * 身份_item(身份一对多)
 * 
 * @author zkcn
 * @email youeremail@163.com
 * @date 2018-01-15 16:20:33
 */
@RestController
@RequestMapping("/api/tidentityitem")
public class TIdentityItemController {
	@Autowired
	private TIdentityItemService tIdentityItemService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("api:tidentityitem:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<TIdentityItemEntity> tIdentityItemList = tIdentityItemService.queryList(query);
		int total = tIdentityItemService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(tIdentityItemList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("api:tidentityitem:info")
	public R info(@PathVariable("id") Long id){
		TIdentityItemEntity tIdentityItem = tIdentityItemService.queryObject(id);
		
		return R.ok().put("tIdentityItem", tIdentityItem);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("api:tidentityitem:save")
	public R save(@RequestBody TIdentityItemEntity tIdentityItem){
		tIdentityItemService.save(tIdentityItem);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("api:tidentityitem:update")
	public R update(@RequestBody TIdentityItemEntity tIdentityItem){
		tIdentityItemService.update(tIdentityItem);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("api:tidentityitem:delete")
	public R delete(@RequestBody Long[] ids){
		tIdentityItemService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
